草庐IT

node.js - 在 TypeScript 中使用 process.env

全部标签

javascript - JS Intl 符号后的空格

我想用NumberFormatofIntl格式化货币并得到返回值,符号和数字之间有一个空格“”。newIntl.NumberFormat('pt-br',{style:'currency',currency:'USD'}).format(12345)//"US$12.345,00"newIntl.NumberFormat('pt-br',{style:'currency',currency:'BRL'}).format(12345)//"R$12.345,00"我要的是:“US$12.345,00”,“R$12.345,00”有什么想法吗? 最佳答案

javascript - 将 Vue.js 与 Typescript 一起使用时如何使用 vue-resource 等插件?

我开始使用Typescript并尝试将其应用到我的项目中。但是,我无法使用vue-resource等Vue.js插件。当我使用this.$http.post()我得到错误:errorTS2339:Property'$http'doesnotexistontype'typeofVue'.这是有道理的,因为我在类里面。但是我该怎么做呢?这是我的完整组件:SignupNamePleaseprovideaname.PasswordPleaseprovideapassword.importComponentfrom'vue-class-component'@Componentexportdefa

javascript - 使用 Redux、React 和 react-router-dom 4.x 时从动态组件获取 ref

我有以下类(class)classMatchBoxextendsReact.Component{constructor(props){super(props);this.countdownHandler=null;this.showBlocker=true;this.start=this.start.bind(this);}start(){...}render(){...return(...);}};functionmapStateToProps(state){...}functionmatchDispatchToProps(dispatch){...}exportdefaultwit

javascript - 定义流文字类型时使用外部常量

我想使用流文字类型的包中的导入常量并静态检查开关;有没有办法做到这一点?(示例如下)//action/types.jsimport{REHYDRATE}from'redux-persist/constants'exporttypeFooBar={foo:number,bar:string,};exporttypeAction={type:'FETCH_REQUEST',data:FooBar[]}|{type:REHYDRATE,payload:any}// 最佳答案 Flow不支持在类型定义中使用包含常量的变量。您必须在定义中使用

javascript - 何时在 JavaScript 中使用 Set

我只是javaScript的初学者,有python背景。我正在尝试这个练习来检查string2的每个字符是否都包含在string1中。例如,如果string1是“hello”,如果string2是“leh”和false,我将返回true>如果string2是“低”。我想到的是这个:functionmutation(arr){varset=newSet(string1.split(''));for(vari=0;i我也可以着手将string2转换为Set,然后取差值,即set(string2)-set(string1)的操作,这将获取我String2中但不在String1中的一组字符,但

javascript - d3.js 在悬停时传递多个函数

我使用教程在鼠标悬停时获得此功能:functionarcTween(outerRadius,delay){returnfunction(){d3.select(this).transition().delay(delay).attrTween("d",function(d){vari=d3.interpolate(d.outerRadius,outerRadius);returnfunction(t){d.outerRadius=i(t);returnarc(d);};});};}然后我以这种方式将其添加到饼图的各个部分:.on("mouseover",arcTween(outerRa

javascript - Vue Js - 无法读取未定义的属性 - (但它在浏览器上呈现)

我在Vue上有这种奇怪的行为。我正在尝试呈现一个名为descrizione的对象的嵌套属性并且它有效!但在控制台中,我收到来自Vue的警告:TypeError:Cannotreadproperty'descrizione'ofundefined"这是我的代码:HTML{{modello.lineaGialla.descrizione}}{{modello.lineaBlu.descrizione}}JSON{"lineaGialla":{"class":"gialla","selected":false,"descrizione":"Questaèlineagialla","descr

javascript - 使用 let 变量而不是使用全局变量

我听说在JavaScript中使用全局变量是不好的。由于let是block作用域的,我可以在包含所有其他函数的block中使用它并以与全局变量类似的方式使用它吗?{varb=10;letc=20;functionfoo(){returnc;}} 最佳答案 是的,您可以,但需要注意(见下文)。在您的示例中,b是全局的,但c不是。请注意,该代码中的foo是松散模式下的全局变量,因此如果您要这样做,请在顶部使用"usestrict";你的代码。另请注意,并非所有浏览器都正确支持let、block中的函数声明等的ES2015语义。要支持尚不

javascript - 如何在for循环中使用angular http rest api保证顺序?

我正在尝试创建一个允许您按顺序创建多个资源的表单。下面的例子Floor1Floor2Floor3...Floor9代码的问题是不能保证顺序。下面是我的代码letstartAt=this.addAreasForm.controls['startAt'].valueconstname=this.addAreasForm.controls['name'].valueconstnewArea={name:name}for(leti=1;ithis.added.emit(area))}可以回来点赞Floor2Floor3Floor1Floor5Floor4您如何处理异步API调用以保证顺序?

javascript - 如何使用 TypeScript 将拖动事件处理程序附加到 React 组件

我正在使用TypeScript(2.4.2)首次涉足React(15.6.1),我正在尝试创建一个组件来表示可拖动的JSON字段。这是我的组件代码:import*asReactfrom"react";interfaceJsonFieldProps{name:string;type:string;indent:number;}exportclassJsonFieldextendsReact.Component{marginStyle={'text-indent':`${this.props.indent*15}px`};render(){return{this.props.name}:{